<?php $this->context->layout = 'form';?>
<?= \common\widgets\Asset::widget(['type'=>['select2']])?>
<form class="form-horizontal m" id="form-admin-add">
    <input type="hidden" name="id" value="<?=$info['id']??''?>">
    <?= \common\widgets\FormInput::widget(['name'=>'formselect|校区','extend'=>['name'=>'campus_id','data'=>$classify??[],'showvalue'=>'id','showname'=>'name','place'=>'','value'=>$info['campus_id']??'','class'=>'select2','tips'=>'不选择将不限制使用校区']])?>
    <?= \common\widgets\FormInput::widget(['name'=>'forminput|标题','extend'=>['name'=>'title','tips'=>'不填写将使用默认标题，如:分享拉新优惠券','info'=>$info]])?>
    <?= \common\widgets\FormInput::widget(['name'=>'formradio|类型','extend'=>['name'=>'type','required'=>1,'data'=>$coupon_type,'info'=>$info]])?>
    <div class="type type-1">
        <?= \common\widgets\FormInput::widget(['name'=>'forminput|充值金额','extend'=>['name'=>'recharge_amount','type'=>'number','info'=>$info]])?>
    </div>
    <div class="type type-2">
        <?= \common\widgets\FormInput::widget(['name'=>'forminput|邀请人数','extend'=>['name'=>'invit_num','type'=>'number','info'=>$info]])?>
    </div>
    <?= \common\widgets\FormInput::widget(['name'=>'forminput|优惠金额','extend'=>['name'=>'discount_amount','required'=>1,'type'=>'number','info'=>$info]])?>
    <?= \common\widgets\FormInput::widget(['name'=>'forminput|排序','extend'=>['name'=>'sort','type'=>'number','required'=>1,'info'=>$info,'tips'=>'排序值越大越靠前']])?>
    <?= \common\widgets\FormInput::widget(['name'=>'formradio|状态','extend'=>['name'=>'status','required'=>1,'info'=>$info]])?>
</form>

<?php $this->beginBlock('script'); ?>
<script>
    var type = "<?=$info['type']?>"
    $('.type').hide();
    $('.type-'+type).show();
    $('body').on('ifChecked','.type_field input',function (event) {
        var value = $(this).val();
        $('.type').hide();
        $('.type-'+value).show();

    })
    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(oesUrl, $('#form-admin-add').serialize());
        }
    }
</script>
<?php $this->endBlock(); ?>
